package util;

import org.apache.commons.lang.StringUtils;

public class PathUtil {
	public static String getCurrentClasPath(Class clazz) {
		if (clazz == null) {
			throw new NullPointerException("clazz should not be null");
		}
		
		Package clazzPackage = clazz.getPackage();
		String packageStr = clazzPackage.getName();

		StringBuffer pathBf = new StringBuffer();
		pathBf.append(System.getProperty("java.class.path"));
		pathBf.append("\\");
		pathBf.append(convertPackageToPath(packageStr));

		return pathBf.toString();
	}

	public static String convertPackageToPath(String packageStr) {
		if (StringUtils.isBlank(packageStr)) {
			throw new NullPointerException("packageStr should not be blank.");
		}
		return packageStr.replace('.', '\\');
	}
}
